//
//  LDJ_WorldCell.m
//  Pianke
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 dada. All rights reserved.
//

#import "LDJ_WorldCell.h"

@implementation LDJ_WorldCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)createSubView{
    
    
    //类型
    self.type = [[UILabel alloc]init];
    self.type.font = [UIFont systemFontOfSize:12];
    self.type.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    [self.contentView addSubview:self.type];
    [self.type mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.left.mas_equalTo(20 * EACH_WIDTH);
        make.top.mas_equalTo(10 * EACH_HEIGHT);
        
    }];
    
    
    
    
    //图片
    self.cellImageView = [[UIImageView alloc]init];
    self.cellImageView.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.cellImageView];
    [self.cellImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40 * EACH_WIDTH, 140 * EACH_HEIGHT));
        make.left.equalTo(self.type);
        make.top.mas_equalTo(self.type.mas_bottom).offset(20 * EACH_HEIGHT);
        
    }];
    
    
    
    //标题
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = [UIFont systemFontOfSize:20 * EACH_HEIGHT];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.cellImageView);
        make.top.mas_equalTo(self.cellImageView.mas_bottom).offset(20 * EACH_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 80 * EACH_WIDTH, 20 * EACH_HEIGHT));
        
    }];
    
    
    //内容
    self.content = [[UILabel alloc]init];
    self.content.font = [UIFont systemFontOfSize:16 * EACH_HEIGHT];
    self.content.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    self.content.numberOfLines = 3;
    [self.contentView addSubview:self.content];
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * EACH_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40 * EACH_WIDTH, 60 * EACH_HEIGHT));
        
    }];
    
    //心形图
    self.heartButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.heartButton  setImage:[UIImage imageNamed:@"iconfont-xinxihuan00-2.png"] forState:UIControlStateNormal];
    [self.contentView addSubview: self.heartButton];
    [self.heartButton addTarget:self action:@selector(heartButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.heartButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(15 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.top.mas_equalTo(self.content.mas_bottom).offset(30 * EACH_HEIGHT);
        make.right.mas_equalTo(-60);
        
        
    }];
    
    
    //赞数
    self.zanLabel = [[UILabel alloc]init];
    self.zanLabel.font = [UIFont systemFontOfSize:EACH_HEIGHT * 12];
    self.zanLabel.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    self.zanLabel.text = @"311";
    [self.contentView addSubview:self.zanLabel];
    [self.zanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(50 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.left.mas_equalTo(self.heartButton.mas_right).offset(10);
        make.top.equalTo(self.heartButton);
        
    }];
    
}

-(void)setWorldModel:(LDJ_HomeModel *)worldModel{
    
    NSString *str = [NSString stringWithFormat:@"%@•%@",worldModel.name,worldModel.enname];
    self.type.text = str;
    self.titleLabel.text = worldModel.title;
    self.content.text = worldModel.content;
    NSString *string = [NSString stringWithFormat:@"%@", worldModel.like];
    self.zanLabel.text = string;
    
    [self.cellImageView sd_setImageWithURL:worldModel.coverimg placeholderImage:[UIImage imageNamed:@"u=1640821638,783268506&fm=21&gp=0.jpg"]];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end

